blktap2: A final few NetBSD fixes
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 24 Jun 2009 14:24:53 +0000 (15:24 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 24 Jun 2009 14:24:53 +0000 (15:24 +0100)
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
tools/blktap2/include/blk_uuid.h
tools/blktap2/vhd/lib/libvhd.c
tools/blktap2/vhd/lib/vhd-util-read.c

index 82922619e0e4017659542d1c58f1065e03997dc0..598ab2b66149f4a8ccec4eb2bc3dbda228be72d8 100644 (file)
@@ -45,7 +45,7 @@ static inline void blk_uuid_generate(blk_uuid_t *uuid)
        uuid_generate(uuid->uuid);
 }
 
-static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out)
+static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out, size_t size)
 {
        uuid_unparse(uuid->uuid, out);
 }
@@ -74,6 +74,7 @@ static inline int blk_uuid_compare(blk_uuid_t *uuid1, blk_uuid_t *uuid2)
 
 #include <uuid.h>
 #include <string.h>
+#include <stdlib.h>
 
 typedef uuid_t blk_uuid_t;
 
@@ -89,10 +90,13 @@ static inline void blk_uuid_generate(blk_uuid_t *uuid)
        uuid_create((uuid_t *)uuid, &status);
 }
 
-static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out)
+static inline void blk_uuid_to_string(blk_uuid_t *uuid, char *out, size_t size)
 {
        uint32_t status;
-       uuid_to_string((uuid_t *)uuid, &out, &status);
+       char *_out = NULL;
+       uuid_to_string((uuid_t *)uuid, &_out, &status);
+       strlcpy(out, _out, size);
+       free(_out);
 }
 
 static inline void blk_uuid_from_string(blk_uuid_t *uuid, const char *in)
index 03bee720c52c5d8892d7c626da605e26a8e5f4c5..1dd36238e63a52e39e63c3f0c255b4f144282e1a 100644 (file)
@@ -1335,7 +1335,7 @@ vhd_macx_encode_location(char *name, char **out, int *outlen)
        snprintf(uri, ibl+1, "file://%s", name);
 
        if (iconv(cd,
-#if defined(__linux__) || (__Linux__)
+#if defined(__linux__) || defined(__Linux__)
            (char **)
 #endif
            &urip, &ibl, &uri_utf8p, &obl) == (size_t)-1 ||
@@ -1425,7 +1425,7 @@ vhd_w2u_encode_location(char *name, char **out, int *outlen)
        }
 
        if (iconv(cd,
-#if defined(__linux__) || (__Linux__)
+#if defined(__linux__) || defined(__Linux__)
            (char **)
 #endif
            &urip, &ibl, &uri_utf16p, &obl) == (size_t)-1 ||
index 0afb3dcceb3bf34287d265773a8ca353d898cea5..2e8dc8b786f9aca5f0acb7932375b7ccd502934e 100644 (file)
@@ -78,7 +78,7 @@ vhd_print_header(vhd_context_t *vhd, vhd_header_t *h, int hex)
               (err ? "failed to read name" : name));
        free(name);
 
-       blk_uuid_to_string(&h->prt_uuid, uuid);
+       blk_uuid_to_string(&h->prt_uuid, uuid, sizeof(uuid));
        printf("Parent UUID         : %s\n", uuid);
     
        vhd_time_to_string(h->prt_ts, time_str);
@@ -153,7 +153,7 @@ vhd_print_footer(vhd_footer_t *f, int hex)
        printf("Checksum            : 0x%x|0x%x (%s)\n", f->checksum, cksm,
                f->checksum == cksm ? "Good!" : "Bad!");
 
-       blk_uuid_to_string(&f->uuid, uuid);
+       blk_uuid_to_string(&f->uuid, uuid, sizeof(uuid));
        printf("UUID                : %s\n", uuid);
 
        printf("Saved state         : %s\n", f->saved == 0 ? "No" : "Yes");